package com.sx.zongzhi.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.sx.zongzhi.R;
import com.sx.zongzhi.bean.PopulationFixedDetailBean;

import butterknife.BindView;
import butterknife.ButterKnife;
import io.reactivex.disposables.Disposable;

/**
 * 常住人口业务信息详情
 */
public class FixedBusinessFragment extends Fragment {

    @BindView(R.id.tv_Health) TextView tv_Health;
    @BindView(R.id.et_YearInCome) TextView tv_YearInCome;
    @BindView(R.id.tv_FixedType) TextView tv_FixedType;
    @BindView(R.id.tv_Remark) TextView tv_Remark;
    @BindView(R.id.tv_IDCardNum) TextView tv_IDCardNum;
    @BindView(R.id.tv_KeyName) TextView tv_KeyName;
    @BindView(R.id.tv_FaMHealth) TextView tv_FaMHealth;
    @BindView(R.id.tv_Relation) TextView tv_Relation;
    @BindView(R.id.tv_Contact) TextView tv_Contact;
    @BindView(R.id.et_FaMInCome) TextView tv_FaMInCome;
    @BindView(R.id.et_FaMAddress) TextView tv_FaMAddress;
    @BindView(R.id.et_Difficult) TextView tv_Difficult;
    @BindView(R.id.et_Help) TextView tv_Help;

    private Disposable disposable;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_fixed_infor,container,false);
        ButterKnife.bind(this,view);
        PopulationFixedDetailBean detailBean = (PopulationFixedDetailBean)
                getArguments().getSerializable("PopulationFixedDetailBean");
        initView(detailBean);
        return view;
    }

    private void initView(PopulationFixedDetailBean detailBean) {
        tv_Health.setText(detailBean.getHealth()!=null?detailBean.getHealth().getDisplayName():"未知");
        tv_YearInCome.setText(detailBean.getPersonalAnnualIncome()+"元");
        tv_FixedType.setText(detailBean.getLeftType()!=null?detailBean.getLeftType().getDisplayName():"未知");
        tv_Remark.setText(detailBean.getHouseholdIdentity()!=null?
                detailBean.getHouseholdIdentity().getDisplayName():"未知");
        tv_IDCardNum.setText(detailBean.getFamilyMainIdCard());
        tv_KeyName.setText(detailBean.getFamilyMainName());
        tv_FaMHealth.setText(detailBean.getFamilyMainHealth()!=null?
            detailBean.getFamilyMainHealth().getDisplayName():"未知");
        tv_Relation.setText(detailBean.getLeftRelationship()!=null?
                detailBean.getLeftRelationship().getDisplayName():"未知");
        tv_Contact.setText(detailBean.getFamilyMainPhone()+" "+detailBean.getFamilyTelephone());
        tv_FaMInCome.setText(detailBean.getFamilyAnnualIncome()+"元");
        tv_FaMAddress.setText(detailBean.getFamilyMainAdress());
        tv_Difficult.setText(detailBean.getDifficultiesAndDemands());
        tv_Help.setText(detailBean.getHelpingSituation());
    }


    @Override
    public void onDestroyView() {
        if (disposable!=null){
            disposable.dispose();
        }
        super.onDestroyView();

    }

}
